package com.jishaokang.util;

import com.jishaokang.dao.MessageDAO;
import com.jishaokang.model.dto.Live;
import com.jishaokang.model.dto.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by NANA_Final on 2019/7/1.
 */
@Component
public class MessageUtil {

    @Autowired
    private MessageDAO messageDAO;

    public void sendSystemMessage(String messageContent,int receiverId){
        Message message = new Message();
        message.setMessageType(0);
        message.setReceiverId(receiverId);
        message.setMessageContent(messageContent);
        message.setSenderId(0);
        message.setCourseId(0);
        message.setChapterId(0);
        messageDAO.insert(message);
    }

    public void sendCourseCommentMessage(String messageContent,int senderId,int receiverId,int courseId,int chapterId){
        Message message = new Message();
        message.setMessageType(1);
        message.setReceiverId(receiverId);
        message.setMessageContent(messageContent);
        message.setSenderId(senderId);
        message.setCourseId(courseId);
        message.setChapterId(chapterId);
        messageDAO.insert(message);
    }

}
